package se.com.movie.reader.model;

public class Extension implements Comparable<Object> {
	private String mExtension;

	public Extension() {
	}

	public Extension(String extension) {
		mExtension = extension;
	}

	public void setExtension(String extension) {
		mExtension = extension;
	}

	public String getExtension() {
		return mExtension;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (obj instanceof String) {
			return compareString((String) obj);
		} else if (obj instanceof Extension) {
			return compareExtension((Extension) obj);
		}
		return false;
	}

	private boolean compareExtension(Extension obj) {
		return mExtension.equalsIgnoreCase(obj.mExtension);
	}

	private boolean compareString(String obj) {
		return mExtension.equalsIgnoreCase(obj);
	}

	@Override
	public int compareTo(Object obj) {
		if (obj instanceof String) {
			return mExtension.compareToIgnoreCase((String) obj);
		} else if (obj instanceof Extension) {
			return mExtension.compareToIgnoreCase(((Extension) obj).mExtension);
		}
		return 0;
	}
}
